package com.xzavier.yunlian_interview.controller;

import com.xzavier.yunlian_interview.entity.ApifoxModel;
import com.xzavier.yunlian_interview.entity.QuestionItem;
import com.xzavier.yunlian_interview.entity.QuestionRecord;
import com.xzavier.yunlian_interview.entity.TechSkills;
import com.xzavier.yunlian_interview.service.QuestionItemService;
import com.xzavier.yunlian_interview.service.QuestionRecordService;
import com.xzavier.yunlian_interview.service.TechSkillsService;
import com.xzavier.yunlian_interview.utils.JsonResult;
import com.xzavier.yunlian_interview.utils.QuestionTotal;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("interview/question")
public class QuestionController {
    @Autowired
    private TechSkillsService techSkillsService;

    @Autowired
    private QuestionItemService questionItemService;


    @GetMapping("type")
    public JsonResult<List<TechSkills>> findAll() {
        List<TechSkills> all = techSkillsService.findAll();
        var result = new JsonResult<List<TechSkills>>(200, all);
        result.setMessage("sucess");
        return result;
    }

    @GetMapping("list")
    public JsonResult<QuestionTotal> getQuestionTotal(ApifoxModel apifoxModel) {
        QuestionTotal questionTotal = questionItemService.getQuestionTotal(apifoxModel);
        return new JsonResult<QuestionTotal>(200, questionTotal);
    }

    @GetMapping("{id}")
    public JsonResult<QuestionItem> getQuestionItem(@PathVariable("id") String id) {
        QuestionItem questionItem = questionItemService.getQuestionItem(id);
        return new JsonResult<QuestionItem>(200, questionItem);

    }


}
